package cn.com.gridinfo.sooc.core.expand.score.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.jeremy.arad.utils.Log;

import java.util.List;

import cn.com.gridinfo.sooc.R;
import cn.com.gridinfo.sooc.core.expand.score.bean.Rate;

/**
 * 提现方式区域的GridView的适配器
 *
 * @author yingchunli
 */
public class GridTxAdapter extends BaseAdapter {

    private Context context;
    private List<Rate> list;
    private int selectPosition = -1;//默认没有任何选中

    public GridTxAdapter(Context context, List<Rate> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = LayoutInflater.from(context).inflate(R.layout.expand_sccore_txtype_item, null);
        LinearLayout layItem = (LinearLayout) convertView.findViewById(R.id.score_item);
        //当前所选的位置 背景更换
        if (selectPosition == position) {
            //选中背景
            layItem.setBackgroundResource(R.mipmap.expand_tx_redbag_pass);
        } else {
            //未选中背景
            layItem.setBackgroundResource(R.mipmap.expand_tx_redbag_normal);
        }

        TextView textView = (TextView) convertView.findViewById(R.id.txcounts_item);
        TextView textView1 = (TextView) convertView.findViewById(R.id.txjifen_item);

        textView.setText(list.get(position).getJe() + "元");
        textView1.setText(list.get(position).getSxjfzs() + "积分");
        return convertView;
    }

    //选中刷新列表
    public void selectRefresh(int selectPosition) {
        this.selectPosition = selectPosition;
        notifyDataSetChanged();
    }

}
